import { Entity, Column, OneToMany } from 'typeorm'
import { BaseEntity } from './Base'
import { LicenseRecord } from './License'

@Entity('users')
export class User extends BaseEntity {
    @Column({
        length: 255,
        unique: true,
        comment: '微信OPENID'
    })
    openid: string

    @Column({
        length: 50,
        comment: '用户级别'
    })
    level: string

    @Column({
        length: 255,
        comment: 'SESSION_KEY'
    })
    sessionKey: string

    @Column({
        length: 50,
        comment: '用户名'
    })
    nickName: string

    @Column({
        length: 255,
        comment: '头像URL'
    })
    avatar: string

    @OneToMany(() => LicenseRecord, (licenseRecord) => licenseRecord.user)
    licenseRecords: LicenseRecord[]
}
